home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / OFFICE.DE-DE / OFFICELR.CAB / COLLECTSIGNATURES_INIT.XSN_1031 / script.js < prev    next >
Text File  |  2006-10-26  |  4KB  |  104 lines

  1. /*
  2.  * This file contains functions for data validation and form-level events.
  3.  * Because the functions are referenced in the form definition (.xsf) file, 
  4.  * it is recommended that you do not modify the name of the function,
  5.  * or the name and number of arguments.
  6.  *
  7. */
  8.  
  9. // The following line is created by Microsoft Office InfoPath to define the prefixes
  10. // for all the known namespaces in the main XML data file.
  11. // Any modification to the form files made outside of InfoPath
  12. // will not be automatically updated.
  13. //<namespacesDefinition>
  14. XDocument.DOM.setProperty("SelectionNamespaces", ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:o12="http://schemas.microsoft.com/office/2004/7/core" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w12="http://schemas.microsoft.com/office/word/2004/6/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
  15. //</namespacesDefinition>
  16.  
  17.  
  18. function AddSigSpotNode(sigline)
  19. {
  20.     sigSpotsNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots");
  21.     
  22.     elemSigSpot = XDocument.DOM.createNode(1, "my:SignatureSpot", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  23.  
  24.     attribSigSpotID = XDocument.DOM.createNode(2, "my:SignatureSpotID", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  25.     attribSigSpotID.text = sigline.Setup.Id;
  26.     attribSuggSigner = XDocument.DOM.createNode(2, "my:SuggestedSigner", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  27.     attribSuggSigner.text = sigline.Setup.SuggestedSigner;
  28.     
  29.     elemSigSpot.setAttributeNode(attribSigSpotID);
  30.     elemSigSpot.setAttributeNode(attribSuggSigner);
  31.         
  32.     elemAssignee = XDocument.DOM.createNode(1, "my:Assignee", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  33.  
  34.     suggSignerEmail = sigline.Setup.SuggestedSignerEmail;
  35.     if (suggSignerEmail)
  36.         {
  37.         elemPerson = XDocument.DOM.createNode(1, "my:Person", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  38.         elemPersonName = XDocument.DOM.createNode(1, "my:DisplayName", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
  39.  
  40.         elemPersonName.text = suggSignerEmail;
  41.  
  42.         elemPerson.appendChild(elemPersonName);
  43.         elemAssignee.appendChild(elemPerson);
  44.         }
  45.  
  46.     elemSigSpot.appendChild(elemAssignee);
  47.     
  48.     sigSpotsNode.appendChild(elemSigSpot);
  49. }
  50.  
  51. function compareSpots(a, b) { return a.SortHint - b.SortHint} 
  52.  
  53. function AddSigSpotNodes(sigSpotsNode)
  54. {
  55.     sigSpotsNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots");
  56.     sigSpotNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots/my:SignatureSpot");
  57.     sigSpotsNode.removeChild(sigSpotNode);
  58.  
  59.     thisDoc = XDocument.Host;
  60.     
  61.     thisDoc.Signatures.Subset = 2; //msoSignatureSubsetSignatureLines;
  62.  
  63.     // Copy all the signature lines into an array.
  64.     cSigLines = thisDoc.Signatures.Count;
  65.     
  66.     arrSigLines = new Array(cSigLines);
  67.  
  68.     for (iSigLine = 1; iSigLine <= cSigLines; iSigLine++)
  69.         {
  70.         arrSigLines[iSigLine] = thisDoc.Signatures(iSigLine);
  71.         }
  72.  
  73.     // Now sort the array based on the sort hint
  74.     arrSigLines.sort(compareSpots);
  75.  
  76.     for (iSigLine = 0; iSigLine < cSigLines; iSigLine++)
  77.         {
  78.         thisSigLine = arrSigLines[iSigLine];
  79.         if (!thisSigLine.IsSignatureLine || (thisSigLine.IsSigned && thisSigLine.IsValid))
  80.             continue;
  81.  
  82.         AddSigSpotNode(thisSigLine);
  83.         }
  84. }
  85.  
  86. //=======
  87. // The following function handler is created by Microsoft Office InfoPath.
  88. // Do not modify the name of the function, or the name and number of arguments.
  89. // This function is associated with the following field or group (XPath): /my:myFields/my:CC
  90. // Note: Information in this comment is not updated after the function handler is created.
  91. //=======
  92. function XDocument::OnLoad(eventObj)
  93. {
  94.     try
  95.     {
  96.     AddSigSpotNodes();
  97.     }
  98.     catch (e)
  99.     {
  100.     XDocument.UI.Alert(e.message);
  101.     }
  102. }
  103.  
  104.